<?php
include_once "xAP-functions/webincludes.php";
LayoutIphoneHeader("Main");
$ip = $_SERVER['REMOTE_ADDR'];
$results=dbquery("select DeviceID from xap_iphone_device where ip='".dbesc($ip)."'");
if(intval($results[0]["DeviceID"])==0){
	dbexec("insert into xap_iphone_device (Alias,IP) VALUES ('".dbesc($ip)."','".dbesc($ip)."')");
	$results=dbquery("select DeviceID from xap_iphone_device where ip='".dbesc($ip)."'");
}
$screens=dbquery("SELECT xap_iphone_screen.ScreenID,xap_iphone_screen.Alias FROM xap_iphone_screen
inner join xap_iphone_devicescreen on xap_iphone_screen.screenid=xap_iphone_devicescreen.screenid where
xap_iphone_devicescreen.deviceid=".intval($results[0]["DeviceID"]));


?>
    <div id="WebApp">

        <div id="iHeader">
            <a href="#" id="waBackButton">Back</a>
            <span id="waHeadTitle">Home</span>

        </div>

        <div id="iGroup">

            <div class="iLayer" id="waHome" title="Home">
<?if($screens[0]["Alias"]!=""):?>
                <div class="iMenu">
					<UL class='iArrow'>
<?foreach($screens as $v):?>
						<LI><a rev="async:np" href='/Floorplan/iphone.php?id=<?=$v["ScreenID"]?>#_Layer1'><?=$v["Alias"]?></a></LI>
<?endforeach?>
					</UL>
                </div>
<?endif?>
                <div class="iMenu">
					<UL class='iArrow'>
						<LI><a rev="async:np" href='/News/iphone.php#_NewsList'>News</a></LI>
						<LI><a rev="async:np" href='/Pictures/iphone.php#_PicturesSources'>Pictures</a></LI>
					</UL>
                </div>
            </div>
        </div>
    </div>
<script>
var PageTimer=0;
WA.AddEventListener("beginslide", LoadFunc);
function LoadFunc(evt) {
// some page may have timer,, clear it on load to prevent background loads
    if (evt.context[1] == "") {
		$('#PageBase').html("");
		clearTimeout ( PageTimer );
    }
}
</script>
<?php
LayoutIphoneFooter();
?>